package com.qf.bigdata.controller;

import com.alibaba.fastjson.JSONObject;
import com.qf.bigdata.service.RawSQLService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/api/v1")
@ResponseBody
public class RawSQLController {

    @Autowired
    private RawSQLService rawSQLService;

    @RequestMapping(value = "sql",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    public Object query(@RequestBody JSONObject jsonObject){
        String sql=jsonObject.getString("sql");
        return rawSQLService.query(sql);
    }
}
